﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using YJKRevitKernel.CurveUtility.ColinearCurveGroup;
using YJKRevitKernel.CurveUtility.CurveGroupSuite;
using YJKRevitKernel.XYZUtility;
using YJKCopyModel.Basic;
using YJKCopyModel.InteractiveOperation;
using YJKCopyModel.LastFastModeling.AddLabel;
using YJKCopyModel.Models;
using YJKPresentation.Utils;

namespace YJKCopyModel.LastFastModeling
{
	[Grouper(GrouperName = "LastFastModeling")]
	public class LastFastModelingGrouper : IDataGrouper
	{
		public List<RevitModelRequest> GroupData(InputRequest inputRequest)
		{
			List<RevitModelRequest> result;
			try
			{
				LastFastModelingInputRequest lastFastModelingInputRequest = inputRequest as LastFastModelingInputRequest;
				bool flag = lastFastModelingInputRequest == null;
				if (flag)
				{
					result = new List<RevitModelRequest>();
				}
				else
				{
					QuickModelingPara quickModelingPara = lastFastModelingInputRequest.ViewParas as QuickModelingPara;
					string equipType = BussinessCommon.GetEquipType(quickModelingPara);
					bool flag2 = equipType == "给排水@灭火器" && lastFastModelingInputRequest.IsAddLabel;
					if (flag2)
					{
						result = this.GetDataForFireExtinguisher(lastFastModelingInputRequest);
					}
					else
					{
						bool flag3 = equipType == "暖通@风机盘管";
						if (flag3)
						{
							result = this.GetDataForDuctCoil(lastFastModelingInputRequest, quickModelingPara);
						}
						else
						{
							bool flag4 = equipType == "暖通@室内机" || equipType == "暖通@散热器";
							if (flag4)
							{
								bool isSelectBlock = this.CheckIsSeletBlock(quickModelingPara);
								result = this.GetDataForInDoorUnit(lastFastModelingInputRequest, quickModelingPara, isSelectBlock);
							}
							else
							{
								result = this.GetDataForCommonEquip(lastFastModelingInputRequest);
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				result = new List<RevitModelRequest>();
			}
			return result;
		}

		public List<RevitModelRequest> GetDataForCommonEquip(LastFastModelingInputRequest lastInputRequest)
		{
			List<RevitModelRequest> list = new List<RevitModelRequest>();
			List<PointPosBlockInfo> list2 = lastInputRequest.SelectDataMap["SelectedBlocks"].Cast<PointPosBlockInfo>().ToList<PointPosBlockInfo>();
			bool flag = list2 == null || list2.Count <= 0;
			List<RevitModelRequest> result;
			if (flag)
			{
				result = new List<RevitModelRequest>();
			}
			else
			{
				foreach (PointPosBlockInfo pointPosBlockInfo in list2)
				{
					bool flag2 = pointPosBlockInfo == null;
					if (!flag2)
					{
						list.Add(new LastFastModelingRevitModelRequest
						{
							Block = pointPosBlockInfo,
							PlaceFs = lastInputRequest.PlaceFs,
							ViewParas = lastInputRequest.ViewParas
						});
					}
				}
				result = list;
			}
			return result;
		}

		public List<RevitModelRequest> GetDataForFireExtinguisher(LastFastModelingInputRequest lastInputRequest)
		{
			List<RevitModelRequest> list = new List<RevitModelRequest>();
			List<PointPosBlockInfo> list2 = lastInputRequest.SelectDataMap["SelectedBlocks"].Cast<PointPosBlockInfo>().ToList<PointPosBlockInfo>();
			bool flag = list2 == null || list2.Count <= 0;
			List<RevitModelRequest> result;
			if (flag)
			{
				result = new List<RevitModelRequest>();
			}
			else
			{
				List<List<PointPosBlockInfo>> blockGroups = this.GetBlockGroups(list2);
				List<RevitModelRequest> list3 = new List<RevitModelRequest>();
				List<RevitModelRequest> list4 = new List<RevitModelRequest>();
				foreach (List<PointPosBlockInfo> list5 in blockGroups)
				{
					List<LastFastModelingRevitModelRequest> list6 = new List<LastFastModelingRevitModelRequest>();
					foreach (PointPosBlockInfo block in list5)
					{
						LastFastModelingRevitModelRequest lastFastModelingRevitModelRequest = new LastFastModelingRevitModelRequest();
						lastFastModelingRevitModelRequest.Block = block;
						lastFastModelingRevitModelRequest.PlaceFs = lastInputRequest.PlaceFs;
						lastFastModelingRevitModelRequest.ViewParas = lastInputRequest.ViewParas;
						list3.Add(lastFastModelingRevitModelRequest);
						list6.Add(lastFastModelingRevitModelRequest);
					}
					list4.Add(new AddLabelRevitModelRequest
					{
						CreateInstanceRequests = list6,
						ViewParas = lastInputRequest.ViewParas
					});
				}
				list.AddRange(list3);
				list.AddRange(list4);
				result = list;
			}
			return result;
		}

		public List<RevitModelRequest> GetDataForDuctCoil(LastFastModelingInputRequest lastInputRequest, QuickModelingPara viewPara)
		{
			DraughtFanPipePara draughtFanPipePara = viewPara.ChildViewPara as DraughtFanPipePara;
			bool flag = draughtFanPipePara == null;
			List<RevitModelRequest> result;
			if (flag)
			{
				result = new List<RevitModelRequest>();
			}
			else
			{
				double minLength = Common.MMToFeet(1.0);
				double maxLength = Common.MMToFeet(2.0);
				double num = Common.MMToFeet(10.0);
				List<RevitModelRequest> list = new List<RevitModelRequest>();
				bool isSelectBlock = draughtFanPipePara.IsSelectBlock;
				if (isSelectBlock)
				{
					List<string> allDuctCoilBlockNames = SpecialtyXml.GetAllDuctCoilBlockNames();
					List<PointPosBlockInfo> list2 = lastInputRequest.SelectDataMap["SelectedBlocks"].Cast<PointPosBlockInfo>().ToList<PointPosBlockInfo>();
					bool flag2 = list2 == null || list2.Count <= 0;
					if (flag2)
					{
						return new List<RevitModelRequest>();
					}
					bool flag3 = false;
					bool flag4 = true;
					foreach (PointPosBlockInfo pointPosBlockInfo in list2)
					{
						PointPosBlockDuctCoilInfo pointPosBlockDuctCoilInfo = pointPosBlockInfo as PointPosBlockDuctCoilInfo;
						bool flag5 = pointPosBlockDuctCoilInfo == null;
						if (!flag5)
						{
							bool flag6 = flag4;
							if (flag6)
							{
								flag3 = allDuctCoilBlockNames.Contains(pointPosBlockDuctCoilInfo.BlockName);
								flag4 = false;
							}
							LastFastModelingRevitModelRequest lastFastModelingRevitModelRequest = new LastFastModelingRevitModelRequest();
							bool flag7 = flag3;
							if (flag7)
							{
								lastFastModelingRevitModelRequest.Block = pointPosBlockInfo;
							}
							else
							{
								List<Curve> curves = this.MergeCurves(pointPosBlockDuctCoilInfo.LstCurves);
								List<Curve> lstLstCv = this.ExtendLines(curves, minLength, maxLength);
								List<Curve> list3 = BussinessCommon.CreateTransform(lastInputRequest.CurveMultiple, lstLstCv);
								bool flag8 = list3.IsEmpty<Curve>();
								if (flag8)
								{
									continue;
								}
								lastFastModelingRevitModelRequest.Curves = list3;
								lastFastModelingRevitModelRequest.CurveMultiple = lastInputRequest.CurveMultiple;
							}
							lastFastModelingRevitModelRequest.PlaceFs = lastInputRequest.PlaceFs;
							lastFastModelingRevitModelRequest.ViewParas = lastInputRequest.ViewParas;
							list.Add(lastFastModelingRevitModelRequest);
						}
					}
				}
				else
				{
					List<CurveInfo> curveInfos = lastInputRequest.SelectDataMap["SelectedBlocks"].Cast<CurveInfo>().ToList<CurveInfo>();
					List<Curve> curvesFromCurveInfos = this.GetCurvesFromCurveInfos(curveInfos);
					list = this.GetRevitModelRequestFromCurves(lastInputRequest, curvesFromCurveInfos);
				}
				result = list;
			}
			return result;
		}

		public List<RevitModelRequest> GetDataForInDoorUnit(LastFastModelingInputRequest lastInputRequest, QuickModelingPara viewPara, bool isSelectBlock)
		{
			double minLength = Common.MMToFeet(1.0);
			double maxLength = Common.MMToFeet(2.0);
			double num = Common.MMToFeet(10.0);
			List<RevitModelRequest> list = new List<RevitModelRequest>();
			if (isSelectBlock)
			{
				List<PointPosBlockInfo> list2 = lastInputRequest.SelectDataMap["SelectedBlocks"].Cast<PointPosBlockInfo>().ToList<PointPosBlockInfo>();
				bool flag = list2 == null || list2.Count <= 0;
				if (flag)
				{
					return new List<RevitModelRequest>();
				}
				foreach (PointPosBlockInfo pointPosBlockInfo in list2)
				{
					PointPosBlockDuctCoilInfo pointPosBlockDuctCoilInfo = pointPosBlockInfo as PointPosBlockDuctCoilInfo;
					bool flag2 = pointPosBlockDuctCoilInfo == null;
					if (!flag2)
					{
						LastFastModelingRevitModelRequest lastFastModelingRevitModelRequest = new LastFastModelingRevitModelRequest();
						lastFastModelingRevitModelRequest.Block = pointPosBlockInfo;
						List<Curve> curves = this.MergeCurves(pointPosBlockDuctCoilInfo.LstCurves);
						List<Curve> lstLstCv = this.ExtendLines(curves, minLength, maxLength);
						List<Curve> list3 = BussinessCommon.CreateTransform(lastInputRequest.CurveMultiple, lstLstCv);
						bool flag3 = list3.IsEmpty<Curve>();
						if (!flag3)
						{
							lastFastModelingRevitModelRequest.Curves = list3;
							lastFastModelingRevitModelRequest.CurveMultiple = lastInputRequest.CurveMultiple;
							lastFastModelingRevitModelRequest.PlaceFs = lastInputRequest.PlaceFs;
							lastFastModelingRevitModelRequest.ViewParas = lastInputRequest.ViewParas;
							list.Add(lastFastModelingRevitModelRequest);
						}
					}
				}
			}
			else
			{
				List<CurveInfo> curveInfos = lastInputRequest.SelectDataMap["SelectedBlocks"].Cast<CurveInfo>().ToList<CurveInfo>();
				List<Curve> curvesFromCurveInfos = this.GetCurvesFromCurveInfos(curveInfos);
				list = this.GetRevitModelRequestFromCurves(lastInputRequest, curvesFromCurveInfos);
			}
			return list;
		}

		public bool CheckIsSeletBlock(QuickModelingPara viewPara)
		{
			InDoorUnitPara inDoorUnitPara = viewPara.ChildViewPara as InDoorUnitPara;
			bool flag = inDoorUnitPara != null;
			bool result;
			if (flag)
			{
				result = inDoorUnitPara.IsSelectBlock;
			}
			else
			{
				RadiatorPara radiatorPara = viewPara.ChildViewPara as RadiatorPara;
				bool flag2 = radiatorPara != null;
				result = (flag2 && radiatorPara.IsSelectBlock);
			}
			return result;
		}

		private List<RevitModelRequest> GetRevitModelRequestFromCurves(LastFastModelingInputRequest lastInputRequest, List<Curve> curves)
		{
			bool flag = curves == null || curves.Count <= 0;
			List<RevitModelRequest> result;
			if (flag)
			{
				result = new List<RevitModelRequest>();
			}
			else
			{
				double minLength = Common.MMToFeet(1.0);
				double maxLength = Common.MMToFeet(2.0);
				double dExtendLength = Common.MMToFeet(10.0);
				List<RevitModelRequest> list = new List<RevitModelRequest>();
				List<Curve> lineCurves = null;
				List<Curve> list2 = null;
				BussinessCommon.SeparateCloseCurves(curves, out lineCurves, out list2);
				List<Curve> curves2 = this.MergeCurves(lineCurves);
				List<Curve> lstLstCv = this.ExtendLines(curves2, minLength, maxLength);
				List<Curve> curves3 = BussinessCommon.CreateTransform(lastInputRequest.CurveMultiple, lstLstCv);
				List<ICurveGeter> testCurves = this.GetTestCurves(curves3);
				List<List<ICurveGeter>> curves4 = CurveGroupManger.GroupCurvesByIntersection(testCurves, dExtendLength);
				List<List<Curve>> curvesFromICurveGeters = this.GetCurvesFromICurveGeters(curves4);
				List<List<Curve>> curves5 = this.RemoveCurves(curvesFromICurveGeters);
				List<BlockCurveData> blockCurveDatas = this.GetBlockCurveDatas(curves5);
				List<BlockCurveData> list3 = this.RemoveCurvesByContainRelation(blockCurveDatas);
				foreach (BlockCurveData blockCurveData in list3)
				{
					list.Add(new LastFastModelingRevitModelRequest
					{
						Curves = blockCurveData.Curves,
						PlaceFs = lastInputRequest.PlaceFs,
						ViewParas = lastInputRequest.ViewParas,
						CurveMultiple = lastInputRequest.CurveMultiple
					});
				}
				result = list;
			}
			return result;
		}

		private List<List<PointPosBlockInfo>> GetBlockGroups(List<PointPosBlockInfo> needCreateBlocks)
		{
			bool flag = needCreateBlocks == null || needCreateBlocks.Count <= 0;
			List<List<PointPosBlockInfo>> result;
			if (flag)
			{
				result = new List<List<PointPosBlockInfo>>();
			}
			else
			{
				List<List<PointPosBlockInfo>> list = new List<List<PointPosBlockInfo>>();
				while (needCreateBlocks.Count > 0)
				{
					List<PointPosBlockInfo> list2 = new List<PointPosBlockInfo>();
					list2.Add(needCreateBlocks[0]);
					needCreateBlocks.RemoveAt(0);
					PointPosBlockInfo nearBlock = this.GetNearBlock(needCreateBlocks, list2[0]);
					bool flag2 = nearBlock != null;
					if (flag2)
					{
						list2.Add(nearBlock);
						needCreateBlocks.Remove(nearBlock);
					}
					list.Add(list2);
				}
				result = list;
			}
			return result;
		}

		private PointPosBlockInfo GetNearBlock(List<PointPosBlockInfo> needCreateBlocks, PointPosBlockInfo blockInfo)
		{
			bool flag = needCreateBlocks == null || needCreateBlocks.Count <= 0;
			PointPosBlockInfo result;
			if (flag)
			{
				result = null;
			}
			else
			{
				foreach (PointPosBlockInfo pointPosBlockInfo in needCreateBlocks)
				{
					bool flag2 = this.CheckTwoBlockIsGroup(blockInfo, pointPosBlockInfo);
					if (flag2)
					{
						return pointPosBlockInfo;
					}
				}
				result = null;
			}
			return result;
		}

		private bool CheckTwoBlockIsGroup(PointPosBlockInfo blockInfoOne, PointPosBlockInfo blockInfoTwo)
		{
			bool flag = blockInfoOne == null || blockInfoTwo == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XYZ xyz = null;
				XYZ xyz2 = null;
				double num = 0.0;
				double num2 = 0.0;
				bool flag2 = !BussinessCommon.GetBlockCenter(blockInfoOne, out xyz) || !BussinessCommon.GetBlockWidth(blockInfoOne, out num) || !BussinessCommon.GetBlockCenter(blockInfoTwo, out xyz2) || !BussinessCommon.GetBlockWidth(blockInfoTwo, out num2);
				if (flag2)
				{
					result = false;
				}
				else
				{
					XYZ blockFaceDirection = BussinessCommon.GetBlockFaceDirection(blockInfoOne);
					XYZ blockFaceDirection2 = BussinessCommon.GetBlockFaceDirection(blockInfoTwo);
					bool flag3 = blockFaceDirection == null || blockFaceDirection2 == null;
					if (flag3)
					{
						result = false;
					}
					else
					{
						double num3 = 10.0;
						double num4 = blockFaceDirection.AngleTo(blockFaceDirection2) * 180.0 / Math.PI;
						result = (xyz.DistanceTo(xyz2) <= 2.0 * num && num4 < num3);
					}
				}
			}
			return result;
		}

		private List<BlockCurveData> RemoveCurvesByContainRelation(List<BlockCurveData> blockCurveDatas)
		{
			bool flag = blockCurveDatas.IsEmpty<BlockCurveData>();
			List<BlockCurveData> result;
			if (flag)
			{
				result = new List<BlockCurveData>();
			}
			else
			{
				List<BlockCurveData> list = new List<BlockCurveData>();
				foreach (BlockCurveData blockCurveData in blockCurveDatas)
				{
					bool flag2 = !this.CheckCurvesIsInCurves(blockCurveDatas, blockCurveData);
					if (flag2)
					{
						list.Add(blockCurveData);
					}
				}
				result = list;
			}
			return result;
		}

		private bool CheckCurvesIsInCurves(List<BlockCurveData> lstCurveDatas, BlockCurveData curveData)
		{
			bool flag = lstCurveDatas.IsEmpty<BlockCurveData>() || curveData == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				foreach (BlockCurveData blockCurveData in lstCurveDatas)
				{
					bool flag2 = blockCurveData == curveData;
					if (!flag2)
					{
						bool flag3 = this.CheckCurvesIsInCurves(blockCurveData, curveData);
						if (flag3)
						{
							return true;
						}
					}
				}
				result = false;
			}
			return result;
		}

		private bool CheckCurvesIsInCurves(BlockCurveData curveData1, BlockCurveData curveData2)
		{
			bool flag = curveData1 == null || curveData2 == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XYZ pointFromCurve = BussinessCommon.GetPointFromCurve(curveData2.MaxAreaCurves[0]);
				bool flag2 = pointFromCurve == null;
				if (flag2)
				{
					result = false;
				}
				else
				{
					int num = XYZUtilityMethod.PointInPloygon(curveData1.MaxAreaCurves, pointFromCurve);
					bool flag3 = num == 1 || num == 0;
					result = flag3;
				}
			}
			return result;
		}

		private List<BlockCurveData> GetBlockCurveDatas(List<List<Curve>> curves)
		{
			bool flag = curves.IsEmpty<List<Curve>>();
			List<BlockCurveData> result;
			if (flag)
			{
				result = new List<BlockCurveData>();
			}
			else
			{
				List<BlockCurveData> list = new List<BlockCurveData>();
				foreach (List<Curve> curves2 in curves)
				{
					BlockCurveData blockCurveData = this.GetBlockCurveData(curves2);
					bool flag2 = blockCurveData != null;
					if (flag2)
					{
						list.Add(blockCurveData);
					}
				}
				result = list;
			}
			return result;
		}

		private BlockCurveData GetBlockCurveData(List<Curve> curves)
		{
			bool flag = curves.IsEmpty<Curve>();
			BlockCurveData result;
			if (flag)
			{
				result = null;
			}
			else
			{
				List<Curve> maxAreaCurves = null;
				bool flag2 = !BussinessCommon.GetMaxBoundCurves(curves, true, out maxAreaCurves);
				if (flag2)
				{
					result = null;
				}
				else
				{
					result = new BlockCurveData
					{
						Curves = curves,
						MaxAreaCurves = maxAreaCurves
					};
				}
			}
			return result;
		}

		private List<Curve> ExtendLines(List<Curve> curves, double minLength, double maxLength)
		{
			List<Curve> list = new List<Curve>();
			foreach (Curve curve in curves)
			{
				bool flag = curve is Line;
				if (flag)
				{
					list.Add(this.ExtendLine(curve, minLength, maxLength));
				}
				else
				{
					list.Add(curve);
				}
			}
			return list;
		}

		private Curve ExtendLine(Curve c, double minLength, double maxLength)
		{
			XYZ endPoint = c.GetEndPoint(0);
			XYZ endPoint2 = c.GetEndPoint(1);
			double num = endPoint.DistanceTo(endPoint2) / 40.0;
			bool flag = num < minLength;
			if (flag)
			{
				num = minLength;
			}
			bool flag2 = num > maxLength;
			if (flag2)
			{
				num = maxLength;
			}
			XYZ xyz = (endPoint2 - endPoint).Normalize();
			XYZ xyz2 = endPoint - num * xyz;
			XYZ xyz3 = endPoint2 + num * xyz;
			return Line.CreateBound(xyz2, xyz3);
		}

		private List<ICurveGeter> GetTestCurves(List<Curve> curves)
		{
			bool flag = curves.IsEmpty<Curve>();
			List<ICurveGeter> result;
			if (flag)
			{
				result = new List<ICurveGeter>();
			}
			else
			{
				List<ICurveGeter> list = new List<ICurveGeter>();
				foreach (Curve useCurve in curves)
				{
					list.Add(new TestCurve
					{
						UseCurve = useCurve
					});
				}
				result = list;
			}
			return result;
		}

		private List<List<Curve>> GetCurvesFromICurveGeters(List<List<ICurveGeter>> curves)
		{
			bool flag = curves.IsEmpty<List<ICurveGeter>>();
			List<List<Curve>> result;
			if (flag)
			{
				result = new List<List<Curve>>();
			}
			else
			{
				List<List<Curve>> list = new List<List<Curve>>();
				foreach (List<ICurveGeter> list2 in curves)
				{
					bool flag2 = list2.IsEmpty<ICurveGeter>();
					if (!flag2)
					{
						List<Curve> list3 = new List<Curve>();
						foreach (ICurveGeter curveGeter in list2)
						{
							bool flag3 = curveGeter.UseCurve != null;
							if (flag3)
							{
								list3.Add(curveGeter.UseCurve);
							}
						}
						bool flag4 = !list3.IsEmpty<Curve>();
						if (flag4)
						{
							list.Add(list3);
						}
					}
				}
				result = list;
			}
			return result;
		}

		private List<Curve> MergeCurves(List<Curve> lineCurves)
		{
			bool flag = lineCurves == null || lineCurves.Count <= 0;
			List<Curve> result;
			if (flag)
			{
				result = new List<Curve>();
			}
			else
			{
				List<Curve> lineCurves2 = null;
				List<Curve> collection = null;
				BussinessCommon.SeparateCurves(lineCurves, out lineCurves2, out collection);
				List<Curve> list = this.MergeLines(lineCurves2);
				list.AddRange(collection);
				result = list;
			}
			return result;
		}

		private List<Curve> MergeLines(List<Curve> lineCurves)
		{
			bool flag = lineCurves == null || lineCurves.Count <= 0;
			List<Curve> result;
			if (flag)
			{
				result = new List<Curve>();
			}
			else
			{
				ColinearGroupManager colinearGroupManager = new ColinearGroupManager(lineCurves);
				List<List<Curve>> colinearGroup = colinearGroupManager.GetColinearGroup();
				bool flag2 = colinearGroup == null || colinearGroup.Count <= 0;
				if (flag2)
				{
					result = lineCurves;
				}
				else
				{
					List<Curve> list = new List<Curve>();
					foreach (List<Curve> list2 in colinearGroup)
					{
						bool flag3 = list2 != null && list2.Count > 0;
						if (flag3)
						{
							list.AddRange(list2);
						}
					}
					result = list;
				}
			}
			return result;
		}

		private List<List<Curve>> RemoveCurves(List<List<Curve>> intersectedCurves)
		{
			bool flag = intersectedCurves.IsEmpty<List<Curve>>();
			List<List<Curve>> result;
			if (flag)
			{
				result = new List<List<Curve>>();
			}
			else
			{
				List<List<Curve>> list = new List<List<Curve>>();
				foreach (List<Curve> list2 in intersectedCurves)
				{
					bool flag2 = list2 != null && list2.Count > 3;
					if (flag2)
					{
						list.Add(list2);
					}
				}
				result = list;
			}
			return result;
		}

		private List<Curve> GetCurvesFromCurveInfos(List<CurveInfo> curveInfos)
		{
			bool flag = curveInfos == null || curveInfos.Count <= 0;
			List<Curve> result;
			if (flag)
			{
				result = new List<Curve>();
			}
			else
			{
				List<Curve> list = new List<Curve>();
				foreach (CurveInfo curveInfo in curveInfos)
				{
					Curve curveFromCurveInfo = this.GetCurveFromCurveInfo(curveInfo);
					bool flag2 = curveFromCurveInfo != null;
					if (flag2)
					{
						list.Add(curveFromCurveInfo);
					}
				}
				result = list;
			}
			return result;
		}

		private Curve GetCurveFromCurveInfo(CurveInfo curveInfo)
		{
			bool flag = curveInfo == null || curveInfo.ThisCurve == null;
			Curve result;
			if (flag)
			{
				result = null;
			}
			else
			{
				Curve thisCurve = curveInfo.ThisCurve;
				XYZ xyz = null;
				bool flag2 = thisCurve is Arc;
				if (flag2)
				{
					xyz = ((Arc)thisCurve).Center;
				}
				else
				{
					bool flag3 = thisCurve is Ellipse;
					if (flag3)
					{
						xyz = ((Ellipse)thisCurve).Center;
					}
					else
					{
						bool flag4 = thisCurve is Line;
						if (flag4)
						{
							xyz = thisCurve.GetEndPoint(0);
						}
					}
				}
				bool flag5 = Geometry.GreaterThan(Math.Abs(xyz.Z), 0.0);
				if (flag5)
				{
					Transform transform = Transform.CreateTranslation(new XYZ(0.0, 0.0, -xyz.Z));
					result = thisCurve.CreateTransformed(transform);
				}
				else
				{
					result = thisCurve;
				}
			}
			return result;
		}
	}
}
